<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
          integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css"
          integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
            integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd"
            crossorigin="anonymous"></script>

    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>

<style>
    #box {
        width: 200px;
        height: 200px;
        margin: auto;
    }

    #box button {
        margin-left: 65px;
    }

    #box input {
        border: 1px solid skyblue;
    }
</style>
<body>

<div id="box">
    <div class="form-group">
        <label for="username">用户名</label>
        <input type="text" class="form-control" id="username" placeholder="请输入用户名">
    </div>
    <div class="form-group">
        <label for="phone">手机号</label>
        <input type="text" class="form-control" id="phone" placeholder="请输入手机号">
        <button type="button" class="btn btn-primary btn-lg btn-block" style="margin-left: 0" id="code_btn">发送验证码
        </button>
        <input type="text" class="form-control" id="telCode" placeholder="请输入验证码">
    </div>
    <button type="button" class="btn bot btn-default">提交</button>

</div>
</body>
<script>
    $(".bot").click(() => {
        let id = location.search.split("=")[1];
        let uName = $("#username").val();
        let tel = $("#phone").val();
        let telCode = $("#telCode").val();
        if (uName === "" || tel === "") {
            alert("请完善个人信息")
        } else $.post("login/giteeSave", {"uName": uName, "tel": tel, "tokenId": id, "telCode": telCode}, (res) => {
            console.log(res)
            if (res.status) {
                let token = res.data.substr(0, res.data.indexOf("&"))
                let uuid = res.data.split("&")[1]
                window.open("userInfo.html?token=" + token+"&"+uuid)
            }else {
                console.log(res)
            }
        })

        //     if (res.success) {
        //         localStorage.phone = res.data
        //         // window.open("./userInfo.html", "_self")
        //     } else alert(res.msg)
        //
        // }, "json")
    })
    $("#code_btn").click(() => {
        let tel = $("#phone").val();
        if (tel === "") {
            alert("请输入手机号")
        } else {
            axios.post(('/login/sendCode'), {
                tel: tel
            }).then(res => {
                console.log(res.data)
            })
        }
    })
</script>


</html>